package farmers.stream;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

public class A002_set工具类 {

    /*
    集合转字符串
Map转List
List转Map
Map转String
List转String
     */

    @Test
    public void setToString(){
        Set<String> set = new TreeSet<>(Arrays.asList("One", "Two", "Three", "Four", "Five", "Six"));
        System.out.println("Set = " + set);

        String str = String.join(", ", set);
        System.out.println("Comma separated String: "+ str);
    }

    @Test
    public void lsitToString(){
        List<String> list = Arrays.asList("One", "Two", "Three", "Four", "Five", "Six");
        System.out.println("list = " + list);

        String str = String.join(", ", list);
        System.out.println("Comma separated String: "+ str);
    }


    @Test
    public void mapToString(){

        List<String> list = Arrays.asList("One", "Two", "Three", "Four", "Five", "Six");
        System.out.println("list = " + list);

        String str = String.join(", ", list);
        System.out.println("Comma separated String: "+ str);
    }

}
